﻿using CoachingOrganizer.WinPhone.UITools;
using CoachingOrganizer.WinPhone.ViewModels.Tools.EmotionsPack;
using CoachingOrganizer.WinPhone.ViewModels.Tools.MoneyCalculation;
using CoachingOrganizer.WinPhone.ViewModels.Tools.MoodLevel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CoachingOrganizer.WinPhone.Selectors
{
    public class ToolsSelector : DataTemplateSelector
    {
        protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement resourcesContainer = container as FrameworkElement;
            if (resourcesContainer != null)
                resourcesContainer = UIHelper.GetUpperElement<ListView>(resourcesContainer);
            if (resourcesContainer != null)
            {
                if (item is EmotionsPackViewModel)
                    return resourcesContainer.Resources["emotionsPackTemplate"] as DataTemplate;
                if (item is MoodLevelViewModel)
                    return resourcesContainer.Resources["moodLevelTemplate"] as DataTemplate;
                if (item is MoneyCalculationViewModel)
                    return resourcesContainer.Resources["moneyCalculationTemplate"] as DataTemplate;
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}
